/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dbHandler;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Rick
 */
public class DerbyConfigeration {
    static String db;
    static String pw;
    static String dbURL;
    static Connection conn;
    static Properties prop;
    
    static boolean alreadyConnected;

    public DerbyConfigeration(){
        
    }

    public static Connection getConnection(){
          try{

            //establish connection
            Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
            dbURL = "jdbc:derby://localhost:1527/myDB;create=true;user=admin ;password= " + db;
            System.out.println("Attemping Connection");
            conn = DriverManager.getConnection(dbURL);
            System.out.println("Connection Successful");
            alreadyConnected = true;
            //conn.close();

        } catch (ClassNotFoundException ex) {
            System.out.println("Error: " + ex);
        } catch (SQLException ex) {
            System.out.println("Error: " + ex);
        } catch(Exception ex){
            System.out.println("Error: " + ex);
        } 
        
        
        return conn;
    }

    public static void closeConnection(){
        try {
            conn.close();
        } catch (SQLException ex) {
            System.out.println("Error " + ex);
        }
    }

}
